package com.jin.spirng_boot_learn.reactor.demo1;


import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;

public class Client {

    public static class MutiClient implements Runnable {


        @Override
        public void run() {
            String sentence;
            String modifiedSentence;

            BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in));
            Socket clientSocket = null;
            try {
                clientSocket = new Socket("localhost", 7070);

                DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
                //BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
                //sentence = inFromUser.readLine();
                outToServer.writeBytes("Hello ..." + '\n');
                BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
                sentence = inFromServer.readLine();
                System.out.println("Response from Server : " + sentence);
                clientSocket.close();
            } catch (IOException e) {
                e.printStackTrace();
            }


        }
    }


    public static void main(String[] args) throws Exception {

        for (int i = 0; i < 100; i++) {
            new Thread(new MutiClient()).start();
        }


    }
}
